<template>
  <dt-modal-edit ref="edit" :title="title" :label-width="130" :width="500" @ok="onOk"></dt-modal-edit>
</template>

<script>
  import createIncentiveOpt from '../opt/createIncentive.js'
  import incentiveMgr from '@/biz/bonus/incentive'
  import paramsMgr from '@/biz/bonus/params.js'
  import extendMgr from '@/biz/bonus/bonusExtend.js'

  export default {
    data() {
      return {
        info: {
          bonusMonth: '',
          bonusName: '',
          headerType: null
        },
        title: '新建在销激励'
      }
    },
    methods: {
      create() {
        paramsMgr.detail().then((res) => {
          extendMgr.getBoApplyMonth().then((resMonth) => {
            this.info.bonusMonth = resMonth
            this.$refs.edit.show(createIncentiveOpt.options(this, res.isLockTime), this.info)
          })
        })
      },
      hide() {
        this.$refs.edit.hide()
      },
      onOk() {
        incentiveMgr.saveBonusStimulate(this.info).then((res) => {
          this.$emit('success', res)
          this.hide()
        })
      }
    }
  }
</script>

<style></style>
